<div id="page" style="text-align: center;"></div>
<script src="__PUBLIC__/jquery-3.1.1.min.js" charset="utf-8"></script>
<script type="text/javascript">
layui.use(['laypage'],function() {
    var laypage = layui.laypage;
    var actname = '{$actname}';

    // 分页实现
    laypage({
        cont: 'page'
        ,pages: {$allpages} //总页数
        ,groups: 5 //连续显示分页数
        ,crr: '{$pid}'
        ,jump: function(obj, first) {
            if (!first) {
                //得到了当前页，用于向服务端请求对应数据
                var curr = obj.curr;
                $.ajax({
                    url: '{:U("admin/system/'+actname+'")}',
                    type: 'POST',
                    dataType: 'json',
                    data: {'pid': curr},
                })
                .done(function(response) {
                    console.log(response);
                    var list = '';
                    for (var data in response.page_list) {
                        list += '<tr><td><input type="checkbox"value="'+response.page_list[data].id+'"name=""class="selected"></td><td>'+response.page_list[data].id+'</td><td>'+response.page_list[data].title+'</td><td>'+response.page_list[data].link+'</td><td>'+response.page_list[data].link_sort+'</td><td class="td-manage"><a title="编辑"href="javascript:;"onclick="link_edit(\'编辑\',\''+response.url[data]+'\',\'4\',\'\',\'510\')"class="ml-5"style="text-decoration:none"><i class="layui-icon">&#xe642;</i></a><a title="删除"href="javascript:;"onclick="link_del(this,\''+response.page_list[data].id+'\')"style="text-decoration:none"><i class="layui-icon">&#xe640;</i></a></td>'+response.count+'</tr>';

                    }
                    $('#x-link').empty().prepend(list);
                    $('#select-all').prop('checked',false);
                })
                .fail(function() {
                    console.log("error");
                });
            }
        }
    });
});
</script>